home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / progargslib.lha / ProgArgs / Includes / libraries / progargs.h
C/C++ Source or Header  |  1995-04-08  |  9KB  |  268 lines

  1.  
  2. #ifndef LIBRARIES_PROGARGS_H
  3. #define LIBRARIES_PROGARGS_H 1
  4.  
  5. #ifndef EXEC_TYPES_H
  6. #include <exec/types.h>
  7. #endif
  8.  
  9. #ifndef UTILITY_TAGITEM_H
  10. #include <utility/tagitem.h>
  11. #endif
  12.  
  13. #ifndef WORKBENCH_STARTUP_H
  14. #include <workbench/startup.h>
  15. #endif
  16.  
  17. #ifndef WORKBENCH_WORKBENCH_H
  18. #include <workbench/workbench.h>
  19. #endif
  20.  
  21. #ifndef DOS_RDARGS_H
  22. #include <dos/rdargs.h>
  23. #endif
  24.  
  25. struct TagArgs {
  26.     struct TagItem* ta_Arguments;       // argument tag list
  27. };
  28.  
  29. /**
  30.  ** This is where tag argument ID values should start.
  31.  **/
  32.  
  33. #define TAG_ARGENTRY (TAG_USER+0x10000)
  34.  
  35. /**
  36.  ** These are tags which control the behaviour of AddProgArgsA()
  37.  ** and RemProgArgsA().  They affect all tags which sequentially
  38.  ** follow them in the tag list.
  39.  **/
  40.  
  41. #define TAG_ARGCONTROL (TAG_USER+0x8000)
  42.  
  43. #define PAC_RDArgsMode (TAG_ARGCONTROL+1)
  44.      /* BOOL
  45.       * Argument parameters are in ReadArgs() style.
  46.       * Default: FALSE.
  47.       */
  48. #define PAC_CopyMode (TAG_ARGCONTROL+2)
  49.      /* BOOL
  50.       * Copy supplied arguments.
  51.       * Default: FALSE.
  52.       */
  53.  
  54. // Value which can be put into ti_Data when calling RemProgArgsA()
  55. // and RemTagArgsA().
  56.  
  57. #define REMARG_IGNORE   (0)     // Don't remove this argument
  58. #define REMARG_REMOVE   (1)     // Remove this argument
  59.  
  60. struct ArgEntry {
  61.     Tag ae_Argument;                // Argument tag code, > TAG_ARGENTRY
  62.     UBYTE* ae_Template;             // Arg template string, ie "FROM/K/M"
  63.     UBYTE* ae_Description;          // Extended description of argument
  64.     ULONG ae_Flags;                 // Entry codes, see below
  65.     APTR ae_Default;                // Default val if AEFLAG_DEFAULT else NULL
  66.     struct TagItem* ae_Ext;         // Extended info, ALWAYS SET TO NULL
  67. };
  68.  
  69. #define AEFLAG_DEFAULT  (1<<0)      // A default value is supplied
  70. #define AEFLAG_HEXNUM   (1<<1)      // Number should be written as hexadecimal
  71.  
  72. // This is not yet implemented.
  73. #define AEFLAG_BINARY   (1<<2)      // String read/written as binary sequence;
  74.                                     // not NULL-terminated and first ULONG is
  75.                                     // the length of the data in bytes.
  76.  
  77. struct MultiArg {
  78.     UBYTE* ma_String;               // Filename/etc for this entry
  79.     BPTR ma_Directory;              // Lock on directory file is relative to
  80.     struct TagItem* ma_Ext;         // reserved for future use
  81. };
  82.  
  83. struct ProgArgs {
  84.     struct TagItem* pa_Arguments;   // The returned arguments
  85. };
  86.  
  87. /**
  88.  ** These are tags which can be passed to both AllocProgArgsA() and
  89.  ** ExecProgArgsA(), to control the reading and writing of arguments.
  90.  ** These tags may occur multiple times, and each action executes
  91.  ** the order in which the tags are found in the tag list.
  92.  **/
  93.  
  94. // Base program argument tags -- global information. 
  95. #define TAG_PROG_ARGS (TAG_USER+0x1000)
  96.  
  97. #define PA_CLIStartup (TAG_PROG_ARGS+1)
  98.      /* UBYTE*
  99.       * Supply the program's CLI arguments.
  100.       */
  101. #define PA_WBStartup (TAG_PROG_ARGS+2)
  102.      /* struct WBStartup*
  103.       * Supply the program's Workbench startup message.
  104.       */
  105.  
  106. // Special directory values.
  107. #define PADIR_PROGRAM   (0xFFFFFFFF)    // Program directory, PROGDIR:
  108. #define PADIR_CURRENT   (0xFFFFFFFE)    // Process' current directory
  109. #define PADIR_ENV       (0xFFFFFFFD)    // ENV:
  110. #define PADIR_ENVARC    (0xFFFFFFFC)    // ENV: *and* ENVARC:
  111.                                         //   ENV: is first updated, then
  112.                                         //   copied to ENVARC:
  113. #define PADIR_PREFS     (0xFFFFFFFB)    // PREFS:
  114. #define PADIR_PRESETS   (0xFFFFFFFA)    // PREFS:Presets/
  115.                                         //   The 'Presets' dir may be
  116.                                         //   created, if needed.
  117. #define PADIR_TEMP      (0xFFFFFFF9)    // T:
  118.  
  119. #define PA_SetDirectory (TAG_PROG_ARGS+3)
  120.      /* BPTR (Lock)
  121.       * Set directory to read/write files from.
  122.       */
  123. #define PA_EscapeChar   (TAG_PROG_ARGS+4)
  124.      /* UBYTE
  125.       * Set escape character for strings.
  126.       */
  127. #define PA_IgnoreError  (TAG_PROG_ARGS+5)
  128.      /* BOOL
  129.       * Set handling of error conditions.
  130.       */
  131. #define PA_CreateIcon   (TAG_PROG_ARGS+6)
  132.      /* BOOL
  133.       * Set creation of program icon if doesn't exit.
  134.       */
  135. #define PA_CreateDirs   (TAG_PROG_ARGS+7)
  136.      /* BOOL
  137.       * Set automatic creation of file directories.
  138.       */
  139. #define PA_AllComments  (TAG_PROG_ARGS+8)
  140.      /* BOOL
  141.       * Set writing of all arguments as comments.
  142.       */
  143. #define PA_ForceWrite   (TAG_PROG_ARGS+9)
  144.      /* BOOL
  145.       * Set writing of all arguments in the set.
  146.       */
  147. #define PA_TransHook    (TAG_PROG_ARGS+10)
  148.      /* struct Hook*
  149.       * Hook to localize strings.
  150.       */
  151. #define PA_TransObject  (TAG_PROG_ARGS+11)
  152.      /* void*
  153.       * Parameter to pass as 'object' to hook.
  154.       */
  155.  
  156. #define STM_NULL    (0)
  157. #define STM_STRING  (1)
  158.  
  159. struct PA_StrTransMsg {
  160.     ULONG stm_Message;      // STM_STRING or STM_NULL
  161.     ULONG stm_StringID;     // ID to translate
  162. };
  163.  
  164. // Read program argument tags -- read in arguments from external source
  165. #define TAG_READ_PROG_ARGS (TAG_USER+0x2000)
  166.  
  167. #define RPA_CmdInput (TAG_READ_PROG_ARGS+1)
  168.      /* BOOL
  169.       * Do ReadArgs() style parsing of command input.
  170.       */
  171. #define RPA_CmdLine (TAG_READ_PROG_ARGS+2)
  172.      /* BOOL
  173.       * Do ReadArgs() style parsing of command line.
  174.       */
  175. #define RPA_CmdString (TAG_READ_PROG_ARGS+3)
  176.      /* UBYTE*
  177.       * Do ReadArgs() style parsing of string.
  178.       */
  179. #define RPA_WBArguments (TAG_READ_PROG_ARGS+4)
  180.      /* Tag
  181.       * Extract arguments from program's Workbench startup message.
  182.       */
  183. #define RPA_ProgIcon (TAG_READ_PROG_ARGS+5)
  184.      /* BOOL
  185.       * Extract arguments from program's icon.
  186.       */
  187. #define RPA_DiskObjectName (TAG_READ_PROG_ARGS+6)
  188.      /* BOOL
  189.       * Extract arguments from an arbitrary DiskObject.
  190.       */
  191. #define RPA_TextFileName (TAG_READ_PROG_ARGS+7)
  192.      /* BOOL
  193.       * Extract arguments from a text file.
  194.       */
  195.  
  196. // Write program argument tags -- write arguments to an external destination
  197. #define TAG_WRITE_PROG_ARGS (TAG_USER+0x3000)
  198.  
  199. #define WPA_ProgIcon   (TAG_WRITE_PROG_ARGS+1)
  200.      /* BOOL
  201.       * Write tooltypes out to program icon.
  202.       */
  203. #define WPA_DiskObjectName   (TAG_WRITE_PROG_ARGS+2)
  204.      /* UBYTE*
  205.       * Name of file to write disk object to.
  206.       */
  207. #define WPA_TextFileName   (TAG_WRITE_PROG_ARGS+3)
  208.      /* UBYTE*
  209.       * Name of file to write arguments out to as text.
  210.       */
  211.  
  212. /**
  213.  ** The following is not yet implemented.
  214.  **/
  215.  
  216. struct ProgArgTrans {
  217.     APTR pat_UserData;              // For any use.
  218. };
  219.  
  220. struct ProgArgMsg {
  221.     UWORD pam_Version;              // Version code, currently 0.
  222.     WORD pam_Command;               // Message command code, see below.
  223.  
  224.     Tag pam_Argument;               // Argument code tag.
  225.     ULONG pam_Type;                 // Message parameter type, see below.
  226.     
  227.     struct ProgArgTrans* pam_Trans; // Your actual translator.
  228.     struct ProgArgs* pam_ProgArgs;  // Who is sending this message.
  229.     struct TagItem* pam_UserTags;   // Tag list supplied to Alloc/Put/Get().
  230.     APTR pam_Pool;                  // Pool that allocations can be done in.
  231.  
  232.     APTR pam_Value;                 // Value sending/getting
  233.     struct ArgEntry* ae_ArgEntry;   // Associated ArgEntry, MAY BE NULL.
  234.     APTR pam_UserData;              // Whatever you want.  This value is
  235.                                     // associated uniquely with this
  236.                                     // pam_Argument.  It is primarily
  237.                                     // intended for tracking memory which
  238.                                     // you may need for constructing a
  239.                                     // version of the argument being put
  240.                                     // somewhere else.  Ie, if it is setting
  241.                                     // a string gadget, you will need to
  242.                                     // allocate the string and copy the
  243.                                     // value into that rather than directly
  244.                                     // setting it from pam_Value.
  245.                                     // Always initialized to NULL.
  246. };
  247.  
  248. // Commands, placed in pam_Command when message is sent.
  249. #define PAMC_NULL       (0)     // Do nothing
  250. #define PAMC_INITSELF   (1)     // Initialize self, sent during allocation
  251. #define PAMC_TERMSELF   (2)     // Terminate self, sent during free
  252. #define PAMC_PUTARG     (3)     // Giving you this argument value
  253. #define PAMC_GETARG     (4)     // Requesting value of this argument
  254. #define PAMC_FREEARG    (5)     // Free this value, prev ret from PAMC_GETARG
  255.  
  256. // Result code, place in pam_Command before returning.
  257. #define PAMR_OKAY       (0)     // All is fine
  258. #define PAMR_TERMINATE  (-1)    // Terminate translating of arguments
  259.  
  260. // Types, found in pam_Type
  261. #define PAMT_UNKNOWN    (0)     // Unknown type
  262. #define PAMT_BOOLEAN    (1)     // Value is a boolean, TRUE or FALSE
  263. #define PAMT_INTEGER    (2)     // Value is a LONG
  264. #define PAMT_STRING     (3)     // Value is a pointer to a NULL-term string
  265. #define PAMT_MULTIARG   (4)     // Value is a pointer to a MultiArg array
  266.  
  267. #endif
  268.